import config, { equipment } from '@/config'
import RequestBase from '@/utils/request.js'

const safetyBaseRequest = new RequestBase(config.safetyUrl)
const dutyBaseRequest = new RequestBase(config.dutyUrl)
const equipmentReq = new RequestBase(config.equipment)
const notificationReq = new RequestBase(config.notificationUrl)
const eduRequest = new RequestBase(config.education)
const baseInfoRequest = new RequestBase(config.basicInfoUrl)
const specialWorkRequest = new RequestBase(config.specialWorkUrl)

/**
 * 通知未读数量
 */
export function reqUnreadMessageCount() {
  return baseInfoRequest.get(`/notification/message/not-todo-count`)
}

/**
 * 通知列表
 */
export function reqMessageList() {
  return baseInfoRequest.get('/notification/message/list')
}

/**
 * 设置已读
 */

export function reqSetReadMessage(messageId) {
  return baseInfoRequest.post(`/notification/message/read/${messageId}`)
}
/**
 * 设置全部已读
 */
export function reqSetReadAllMessage() {
  return baseInfoRequest.post(`/notification/message/read-all`)
}

// 查看待办消息数量
export function getTodoData() {
  return safetyBaseRequest.get('/business/app/myToDoCount')
}

// 作业票分析待办数量
export function getTicketAnalysisTodoTotal() {
  return specialWorkRequest.get('/mobile/spw/ticket/analysis/count')
}

// 查看待办消息数量(班前会，交接班待办数量)
export function getMyToDoList() {
  return dutyBaseRequest.get('/dtr/mobile/todo/myToDoList')
}

//查询点检，润滑，维护保养待办数量
export function getDeviceTaskMsg() {
  return equipmentReq.get('/mobile/dfm/home-page/myToDo/count')
}

// 查看报警事件数量
export function getWarnEventCount() {
  return notificationReq.get('/ntf/todo-task/count?category=5')
}

// 智能巡检消息数
export function getInspectMsg() {
  return equipmentReq.get('/mobile/dfm/home-page/getStatisticsInfo')
}

//app未读消息列表
export function getNoReadListForApp() {
  return notificationReq.get('/ntf/message-record/getNoReadListForApp')
}

// 未读消息总数
export function getNoReadTotalForApp() {
  return notificationReq.get('/mobile/ntf/message/no/read/total')
}

// 告警消息
export function getNoticeListForApp() {
  return notificationReq.get('/mobile/ntf/message/no/read/statistics')
}

// 标记已读
export function readNotice(data) {
  return notificationReq.put('/mobile/ntf/message/readMessage', data)
}

// 告警列表
export function getWarningListForApp({ title, pageNum, pageSize }) {
  return notificationReq.get(`/mobile/ntf/message/no/read/list?title=${title}&pageNum=${pageNum}&pageSize=${pageSize}`)
}

// 批量标记已读
export function markAsRead(recordIds) {
  return notificationReq.put(`/ntf/message-record/markAsRead/${recordIds}`)
}

// 获取培训任务、在线考试待办
export function reqGetEduTodoCount() {
  return eduRequest.get(`/plan/todo/count`)
}

//  获取装载任务数量
export const getDockWorkCount = () => {
  return safetyBaseRequest.get('/mobile/bsci/dock/work/to-do-task/count')
}
